import Cocoa
import FlutterMacOS

class MainFlutterWindow: NSWindow {
  override func awakeFromNib() {
    let flutterViewController = FlutterViewController()
    let windowFrame = self.frame
    self.contentViewController = flutterViewController
    self.setFrame(windowFrame, display: true)

    RegisterGeneratedPlugins(registry: flutterViewController)
    
      let customView = NSView(frame: NSRect(x: 0, y: 0, width: windowFrame.size.width, height: windowFrame.size.height))
      customView.wantsLayer = true // 允许使用 CALayer
      customView.layer?.backgroundColor = NSColor.white.cgColor // 设置背景颜色

      // 添加到窗口的 contentView
      self.contentView?.addSubview(customView)
      
      DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
          customView.removeFromSuperview()
      }
      
    super.awakeFromNib()
  }
}
